import request from "/utils/request.ts";
import { ListQuests } from "./provide.d";

// 获取验证码
export const getSMSCode = () =>
  request({
    url: "/code",
    method: "GET",
    checkToken: false,
  });

// 登录
export const login = (data: {
  account: string;
  password: string;
}): Promise<{
  data: { token: string };
}> =>
  request({
    url: "/classai/api/login/teacher",
    method: "POST",
    data,
    checkToken: false,
  });

// 登出
export const logout = () =>
  request({
    url: "/classai/api/logout",
    method: "POST",
  });

// 查询老师资料
export const getTeacherById = () =>
  request({
    url: "/classai/api/getTeacherById",
    method: "POST",
  });

// 修改老师资料
export const updateTeacher = (data) =>
  request({
    url: "/classai/api/updateTeacher",
    method: "POST",
    data,
  });

// 修改密码
export const updatePassword = (data: {
  oldPassword: string;
  newPassword: string;
}) =>
  request({
    url: "/classai/api/updatePassword",
    method: "POST",
    data,
  });

// 扫码签到(小程序)
export const trainingScanCodeSignin = (data: { trainingCourseId: string }) =>
  request({
    url: "/classai/api/training/scanCodeSignin",
    method: "GET",
    data,
  });

// 查询我的学分/作业/消息(小程序)
export const trainingGetMyCourseInfo = () =>
  request({
    url: "/classai/api/training/getMyCourseInfo",
    method: "GET",
  });

// 我的消息列表(教师端/小程序)
export const trainingGetMyMessage = (data: ListQuests) =>
  request({
    url: "/classai/api/training/getMyMessage",
    method: "GET",
    data,
  });

// 查询消息详情(教师端/小程序)
export const trainingGetMyMessageById = (data: { msgId: string }) =>
  request({
    url: "/classai/api/training/getMyMessageById",
    method: "GET",
    data,
  });

// 设置消息已读(教师端/小程序)
export const trainingReadMessage = (data: { msgId: string; type: 1 | 0 }) =>
  request({
    url: "/classai/api/training/readMessage",
    method: "GET",
    data,
  });
